package com.ysl.study.designpattern.structure.proxy;

/**
 * 代理模式
 * 代理类  静态代理
 * @author yangshanlin
 * @date 2023/3/3 17:52
 * @describe
 */
public class MovieProxy implements IMovie {

    private Movie movie;

    public MovieProxy(Movie movie){
        this.movie = movie;
    }

    @Override
    public void play(String text) {
        advertising(true);
        movie.play(text);
        advertising(false);
    }

    private void advertising(boolean isBoforMovie){
        if(isBoforMovie){
            System.out.println("影片马上开始");
        }else{
            System.out.println("影片正片已经结束,马上彩蛋环节,不要离开哦");
        }
    }

}
